import Vue from 'vue'


function getChildren(list, pid) {
    let children = list.filter(o => {
        return o.pid == pid;
    });
    children.forEach((item, index) => {
        let children = getChildren(list, item.id);
        if (children.length > 0) {
            // 使用vue.set() 赋值对象属性，否则不能触发computed
            Vue.set(item, 'children', children);
        }
    });
    return children;
}


export {
    getChildren
}